#include "VisitorDisplayLog.h"
#include "..\..\ui_mainwindow.h"
#include "..\..\mainwindow.h"

VisitorDisplayLog::VisitorDisplayLog(QString strLog, QString strWidgetName)
{
    m_strLog = strLog;
    m_strWidgetName = strWidgetName;
}

void VisitorDisplayLog::VisitorElement(IUIElement* pElement)
{
    if (nullptr == pElement)
    {
        return;
    }
    
    MainWindow *pMain = dynamic_cast<MainWindow *>(pElement); 
    if (NULL != pMain)
    {
        QTextEdit *pTextEdit = pMain->findChild<QTextEdit *>(m_strWidgetName);
        if (pTextEdit)
        {
            pTextEdit->append(m_strLog);
        }
    }
}
